package api

import (
	"ims/app/dao"
	"ims/tools/response"
	"time"

	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/net/ghttp"
)

func GetNotice(r *ghttp.Request) {

	kefuId := r.GetQueryString("kefu_id")
	welcomes := dao.FindWelcomesByUserId(kefuId)
	user := dao.FindUser(kefuId)
	result := make([]g.Map, 0)
	for _, welcome := range welcomes {
		h := g.Map{
			"name":    user.Nickname,
			"avator":  user.Avator,
			"is_kefu": false,
			"content": welcome.Content,
			"time":    time.Now().Format("Y-m-d H:i:s"),
		}
		result = append(result, h)
	}
	response.JsonResponse(r, g.Map{
		"code":   200,
		"msg":    "ok",
		"result": result,
	})
}
